import { MockMethod, MockConfig } from 'vite-plugin-mock';
const userList = [
  { username: 'user', password: '123456' },
  { username: 'wenl', password: '123456' },
  { username: 'admin', password: '123456' },
];
export default [
  {
    url: '/api/login',
    method: 'get',
    response: ({ query }) => {
      const user = userList.find(user => user.username === query.username);
      if (user) {
        if (user.password === query.password) {
          return {
            code: 200,
            data: {
              username: 'wenl',
              sex: 'BOY',
              age: 18,
              headerImg:
                'https://files.codelife.cc/blog/avatar/63186d764cd3bdb1a6617771.jpeg?t=1688289491947&x-oss-process=image/resize,limit_0,m_fill,w_100,h_100/quality,q_100',
              worker: '前端', // 职业
              address: '广东·广州', //地址
              github: 'https://gitee.com/wenl121',
              blogUrl: 'https://wenl125539.github.io/blog-press/', // 笔记地址
              tags: ['90后', '运动', '旅游', '游戏', '码字'],
            },
          };
        } else {
          return {
            code: 5001,
            err: '密码错误',
          };
        }
      } else {
        return {
          code: 2001,
          err: '账户不存在',
        };
      }
    },
  },
] as MockMethod[];
